#include<stdio.h>
int bin_search(int arr[], int left, int right, int key)
{
	int ret = 0;
	int mid = 0;
	while (left <= right)
	{
		mid = (left + right) / 2;
		if (arr[mid] > key)
		{
			right = mid - 1;
		}
		else if (arr[mid] < key)
		{
			left = mid + 1;
		}
		else 
		{
			ret = 1;
			break;
		}
	}
	return ret;
	
}
int main()
{
	int arr1[5] = { 1,2,3,4,5 };
	int key = 3;
	int right= sizeof(arr1) / sizeof(arr1[0])-1;
	int left = 0;
	int c=bin_search(arr1, left, right, key);
	printf("%d", c);
	return 0;
}